//
//  LessionDetailViewController.m
//  MM
//
//  Created by 郑渊文 on 5/29/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//

#import "LessionDetailViewController.h"
#import "StoreViewController.h"

@interface LessionDetailViewController ()
{
    UIButton *backBtn;
    UITextView *introduceLable;
}

@end

@implementation LessionDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSDictionary *param4 = @{@"classId":_classId};
    ////NSLog(@"====================%@",_classId);
    [UserDAL getClassdetailParams:param4 withBlock:^(NSDictionary *data, NSError *error) {
        if (data) {
            ////NSLog(@"what%@",data);
            _DetailText = data[@"classIntroduce"];
            //            for (NSDictionary *mydic in array) {
            //
            //            }
            ////NSLog(@"=============================%@",_DetailText);
            
        }else
        {
            
        }
    }];

      [self initSubViews];
//    _DetailText= @"Acting as if nothing borne in mind is the best revenge.It's all for myself to live better.Every day may not be good…but there's something good in every day.Happiness is about having each tiny wish come ture.A woman has got to love a bad man once or twice in her life to be thankful for a good one.";

    
     self.navigationItem.title = @"课程详情";
    [self.navigationController.navigationBar setTranslucent:NO];//设置navigationbar的半透明
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#34bd81" alpha:1]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];

//    self.navigationItem.rightBarButtonItem.title = @"课程详情";
       // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)viewDidAppear:(BOOL)animated
{
     introduceLable.text = _DetailText;
  
}
-(void)viewWillAppear:(BOOL)animated
{

}
-(void)initSubViews
{
    //自定义左右按钮
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:@"_0000_返回.png"]
     
                      forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(back)
     
     forControlEvents:UIControlEventTouchUpInside];
    
    button.frame = CGRectMake(0, 0, 20, 15);
    
    
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    
    
    self.navigationItem.leftBarButtonItem = menuButton;

    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [self.view addSubview:bgView];
    bgView.backgroundColor = [UIColor whiteColor];
    
    UILabel *intrTitle = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2-100, 10, 200, 60)];
    intrTitle.text = @"课程介绍";
    intrTitle.textAlignment = NSTextAlignmentCenter;
    intrTitle.font  = [UIFont systemFontOfSize:25];
    intrTitle.textColor = [UIColor blackColor];
    [bgView addSubview:intrTitle];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 70, SCREEN_WIDTH, 1)];
    lineView.backgroundColor = UIColorWithRGBA(215, 215, 215, 1);
    [bgView addSubview:lineView];
    
//    UILabel *introduceLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH-20, 60)];
//    introduceLable.numberOfLines = 0;
//    introduceLable.font = [UIFont fontWithName:@"Helvetica" size:13];
    
  
    
    introduceLable = [[UITextView alloc]initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH-20, SCREEN_HEIGHT-100)];
    //    introduceLable.numberOfLines = 0;
    introduceLable.editable = NO;
    introduceLable.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高度
    introduceLable.font = [UIFont fontWithName:@"Helvetica" size:13];
    
    [bgView addSubview:introduceLable];
    
//    _mytext= _DetailText;
//    UIFont *font = [UIFont fontWithName:@"Helvetica" size:13.0];
//    CGSize size = [_mytext sizeWithFont:font constrainedToSize:CGSizeMake(SCREEN_WIDTH-20, 2000.0f)
//                       lineBreakMode:NSLineBreakByWordWrapping];
//    CGRect rect = introduceLable.frame;
//    rect.size = size;
//    float viewHeight = size.height;
//    [introduceLable setFrame:rect];
//    [introduceLable setText:_mytext];
//    introduceLable.backgroundColor = [UIColor clearColor];
//    
//    UIView *introduceView = [[UIView alloc]initWithFrame:CGRectMake(10, 80, SCREEN_WIDTH-20, 40+viewHeight)];
//    introduceView.backgroundColor = [UIColor whiteColor];
//    introduceView.layer.borderColor = [UIColor clearColor].CGColor;
//    introduceView.backgroundColor = [UIColor whiteColor];
//    introduceView.layer.borderWidth = 1;
//    
//    [bgView addSubview:introduceView];
//    [introduceView addSubview:introduceLable];
    

//    UIButton *myBtn = [[UIButton alloc]initWithFrame:CGRectMake(50, SCREEN_HEIGHT-150, SCREEN_WIDTH-100, 40)];
//    [myBtn setTitle:@"早教上门" forState:UIControlStateNormal];
//    [myBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [myBtn addTarget:self action:@selector(doorToTeach) forControlEvents:UIControlEventTouchUpInside];
//    myBtn.backgroundColor = UIColorWithRGBA(227, 90,92, 1);
//    [bgView addSubview:myBtn];

}

-(void)doorToTeach
{
//    StoreViewController *setVC = [[StoreViewController alloc]init];
//    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:setVC];
//    [self  presentViewController:nav animated:YES completion:nil];
}

-(void)back
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
